package com.whminwei.edu.api.dc.dto.fspn.other;

import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.util.CollectionUtils;

import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author zhangjq
 * @since 2024-08-13
 */
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@JsonInclude(JsonInclude.Include.NON_NULL)
public class DcMatchFspn {

    private List<DcMatch> matches;

    private List<String> deleted;

    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    @JsonInclude(JsonInclude.Include.NON_NULL)
    public static class DcMatch implements Cloneable {
        private String id;
        /**
         * 赛事名称
         */
        private String name;
        /**
         * 赛事类别
         */
        private String attr;
        /**
         * 赛事类型
         */
        private String type;
        /**
         * 赛事级别
         */
        private String level;
        /**
         * 组织单位
         */
        private String unit;
        /**
         * 参与人员
         */
        private List<DcParticipant> participants;

        @Override
        public DcMatch clone() {
            try {
                DcMatch clone = (DcMatch) super.clone();
                clone.setId(this.id);
                clone.setName(this.name);
                clone.setAttr(this.attr);
                clone.setType(this.type);
                clone.setLevel(this.level);
                clone.setUnit(this.unit);
                if (!CollectionUtils.isEmpty(this.participants)) {
                    clone.setParticipants(this.participants.stream().map(DcParticipant::clone).collect(Collectors.toList()));
                }
                return clone;
            } catch (CloneNotSupportedException e) {
                throw new AssertionError();
            }
        }
    }

    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    @JsonInclude(JsonInclude.Include.NON_NULL)
    public static class DcParticipant implements Cloneable {
        /**
         * 教职工ID
         */
        private String staffId;
        /**
         * 合作情况
         */
        private String sort;
        /**
         * 获奖日期
         */
        private Date awardDate;
        /**
         * 获奖级别
         */
        private String awardLevel;
        /**
         * 其他级别描述
         */
        private String awardLevelDesc;

        @Override
        public DcParticipant clone() {
            try {
                DcParticipant clone = (DcParticipant) super.clone();
                clone.setStaffId(this.staffId);
                clone.setSort(this.sort);
                clone.setAwardDate(this.awardDate);
                clone.setAwardLevel(this.awardLevel);
                clone.setAwardLevelDesc(this.awardLevelDesc);
                return clone;
            } catch (CloneNotSupportedException e) {
                throw new AssertionError();
            }
        }
    }
}
